<?php
include("../config.php");
include("../inc/func.php");
include("../db.php");
$debug = TRUE;
loginCheck();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php site_title();?> Control Panel - Post</title>
<link rel="stylesheet" href="style.css" />
<script type="text/javascript">
    _editor_url  = "../inc/js/xinha"  // (preferably absolute) URL (including trailing slash) where Xinha is installed
    _editor_lang = "en";      // And the language we need to use in the editor
</script>
<script type="text/javascript" src="../inc/js/xinha/XinhaCore.js"></script>
<script type="text/javascript" src="../inc/js/xinha/XinhaConfig.js"></script>
</head>
<body>
<div id="wrap">
  <div id="head">
    <div id="title"><?php site_title(); ?><div class="gotosite"> <a href="../">Go to your site &raquo;</a></div></div>
  </div>
  <div id="nav">
    <ul>
      <li><a href="index.php">Main</a></li>
      <li class="current"><a href="post.php">Post</a></li>
      <li><a href="manage.php">Manage</a></li>
      <li><a href="theme.php">Themes</a></li>
      <li><a href="options.php">Options</a></li>
    </ul>
  </div>
  <div id="content">
  <?php
  if(isset($_GET['type'])) {
  if($_GET['type'] == "text") {
	postform("text");
  }
  elseif($_GET['type'] == "quote") {
	  postform("quote");
  }
  elseif($_GET['type'] == "link") {
	  postform("link");
  }
  elseif($_GET['type'] == "image") {
	  postform("image");
  }
  }
  elseif(isset($_GET['post'])) {
  if($_GET['post'] == "1") {
	  $title = $_POST['title'];
	  $author = $_POST['author'];
	  $date = date('m-d-y');
	  $type = $_POST['type'];
	  $text = $_POST['text'];
	  $text = nl2br($text);
	  global $db_prefix;
	  $query = "INSERT INTO $db_prefix"."posts (title, author, date, type, text) VALUES ('$title', '$author', '$date', '$type', '$text')";
	  mysql_query($query) or die('Error, insert query failed');
	  echo '<div id="success">Posted successfully</div>';
  }
  }
  else {
  ?>
  <div id="postlinks">
  <div class="postlink"><a href="post.php?type=text">Post some text</a></div>
	<div class="postlink"><a href="post.php?type=link">Post a link</a></div>
	<div class="postlink"><a href="post.php?type=quote">Post a quote</a></div>
	<div class="postlink"><a href="post.php?type=image">Post an image</a></div>
  </div>
  <?php } ?>
  </div>
  <div id="footer"><?php LIversion(); ?></div>
</div>
</body>
</html>
